package com.ruoyi.web.controller.app;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.FilmPermitInfo;
import com.ruoyi.system.dto.coopHan.PageCulvertNoticeDto;
import com.ruoyi.system.dto.film.FilmPermitInfoAddDto;
import com.ruoyi.system.dto.film.FilmPermitInfoSearchVo;
import com.ruoyi.system.service.IFilmPermitInfoService;
import com.ruoyi.utils.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 公映许可证信息Controller
 *
 * @author 周志雄
 * @date 2024-03-09
 */
@Api(tags = "(APP)公映许可证信息-公示API")
@RestController
@RequestMapping("/app/system/permitInfo")
public class AppFilmPermitInfoController extends BaseController
{
    @Autowired
    private IFilmPermitInfoService filmPermitInfoService;

    /**
     * 查询公映许可证信息列表
     */
    @ApiOperation("查询公映许可证信息-公示列表")
//    @PreAuthorize("@ss.hasPermi('system:permitInfo:list')")
    @PostMapping("/list")
    public AjaxResult<PageResult<FilmPermitInfo>> list(@RequestBody PageCulvertNoticeDto dto)
    {
        List<FilmPermitInfo> list = filmPermitInfoService.selectpageList(dto);
//        PageRequest pageRequest = new PageRequest(filmPermitInfoSearchVo.getPageNum(), filmPermitInfoSearchVo.getPageSize());
//        PageResult<FilmPermitInfo> pageResult = PaginationHelper.paginateList(list, pageRequest);
        List<FilmPermitInfo> list1 = filmPermitInfoService.list();
        int totalPages = 0;
        if (!list1.isEmpty()){
            totalPages=list1.size()/dto.getPageSize();
        }
        PageResult<FilmPermitInfo> pageResult = new PageResult<>(list1.size(),totalPages,list,dto.getPageNum(),dto.getPageSize());
        return AjaxResult.success(pageResult);
    }



    /**
     * 获取公映许可证信息详细信息
     */
    @ApiOperation("根据ID获取公映许可证信息-公示详请")
    @PreAuthorize("@ss.hasPermi('system:permitInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<FilmPermitInfo> getInfo(@ApiParam(value = "公映许可证ID") @PathVariable("id") Long id)
    {
        return AjaxResult.success(filmPermitInfoService.selectFilmPermitInfoById(id));
    }


}
